<!-- /* Description for file.
 *公司namelist file
 *
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/companymanages
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    张朋2011年0714
 * @lastmodified  张朋2011年0714
 -->
<script type="text/javascript">
$(function(){
		$("#bt_1").click(function () {$(".bt1").click();});
		});
</script>

<script type="text/javascript">
$(function(){

	$(".cf").submit(function(){
		var str = $("[name=appendix]").val();
		var ish = $("[name=appendix] ~ div").html();
		if(typeof(str) == "undefined" && ish == null)
		{
			$("[name=appendix]").after("<div style='color:red' >&nbsp;请选择文件</div>");
			return false;
		} else if(str == ""){
			return false;
		} else {
			return true; 
		}
		
		
	});
	$("[name=appendix]").focus(function(){
		$("[name=appendix] ~ div").remove();
	});
	

});
</script>
 
<!-- 当前位置-->
<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('Customer Managements');//一级目录
										   echo '>';echo __('customer namelist');//二级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('Customer Managements Detail',true).'&nbsp;&nbsp;&nbsp;'.$thedetail['Companymanage']['name']);//当前操作地用span加粗?> 						  
		</td>
	</tr>
</table>
</div>
<!-- 当前位置-->
</div>
<input type="hidden" value="<?php echo $thedetail['Companymanage']['id']?>" class="theid"></input>
<!-- 附件上传 -->
<div class="tabflex">
	<?php echo $form->create('Companymanage',array('action'=>'namelistUpload/'.$thedetail['Companymanage']['id'],'type'=> 'post','class'=>'cf','enctype'=>'multipart/form-data'));?>
		<fieldset><legend><?php echo '公司文档上传'//__('附件上传');?></legend>
			<?php
				echo $form->hidden('creater');
				echo $form->hidden('updater');
				echo $form->hidden('id',array('value'=>$thedetail['Companymanage']['id']));
			?> 
			<div class="tabflex" style="width:60%;" id="d">
				<?php echo $form->file('appendix',array('name'=>'appendix','class' => 'TextBoxL'));?>
			</div>
			<div class="tabflex" style="width:10%;" >
				<?php echo $form->button('增加附件',array('type'=>'submit','class'=>'btn4'));?>
			</div>
			<div class="tabflex" style="width:10%;" >
				<?php echo $form->button('取消附件',array('type'=>'button','class'=>'btn4','id'=>'bt_1'));?>
			</div>
			<div class="tabflex" style="width:10%">
				<?php echo $form->button('删除',array('type'=>'button','class'=>'btn2','id'=>'bt_2'));?>
			</div>
		</fieldset>
	<?php echo $form->end();?>
</div>
<!-- 附件上传 -->

<script language="javascript">
var delurl="<?php echo $deleteurl; ?>";
</script>
<script language="javascript">
var data=<?php echo $data; ?>;
</script>
<script language="javascript">
var disbutton=<?php echo $javascript->object($disbutton);?>;
</script>
<script language="javascript">
var title2="<?php echo $title2; ?>";
</script>
<?php echo $javascript->link('jquery-1.4.2');?>
<script language="javascript">
function button(com,grid,url)  
{  
	var ids=$("#flex").getCheckedRows();
	if(com=="delete")
	{
		var pids="";
		if(ids.length==0)
		{
			alert("请选择你要删除的项");
			return;
		}
		for(i=0;i<ids.length;i++)
        {
        	pids=pids+ids[i]+"/";
        }
		$.ajax({
            type: "post",
            url: url,
            data: {id:pids},
            dataType:"json",
            success: function(data) {
            $(".clearckeck").trigger("click");
			$(".pReload").trigger("click");
			$(".notice").html(data.message); 
			},
            error: function(data) {
				$(".clearckeck").trigger("click");
				$(".pReload").trigger("click");
				$(".notice").html('data.message');
			}
        });
	}
	else if(com=="add")
	{
		window.open(url,'mainFrame2');
	}
	else if(com=="edit")
	{
		if(ids.length!=1)
		{
			alert("请选择一个选项");
		}
		else
		{
			var seid=ids[0];
			var eurl=url+"?id="+seid;
			window.open(eurl,'mainFrame2');
		}
	}
	else
	{
		var pix=com.substring(0,2);
		switch (pix)
		{
			case "aj":
				var pids="";
				if(ids.length==0)
				{
					alert("请选择选项");
					return;
				}
				for(i=0;i<ids.length;i++)
		        {
		        	pids=pids+ids[i]+"/";
		        }
				$.ajax({
		           type: "post",
		           url: url,
		            data: {id:pids},
		            dataType:"json",
		            success: function(data) {
					$(".pReload").trigger("click");
					$(".notice").html(data.message); 
					},
		            error: function(data) {
						$(".clearckeck").trigger("click");
						$(".pReload").trigger("click");
						$(".notice").html('data.message');
					}
		        });
				break;
			case "up":
				if(ids.length!=1)
				{
					alert("请选择一个选项");
				}
				else
				{
					var seid=ids[0];
					var eurl=url+"?id="+seid;
					window.open(eurl,'mainFrame2');
				}
				break;
			default:
				window.open(url,'mainFrame2');
		}
	}
}
</script>
<script type="text/javascript">
var b= '';
</script>
<script type="text/javascript">
var ob=<?php echo $ob;?>;
if(ob.length==0)
{
	
}
else
{
	for(i=0;i<ob.length;i++)
	{
		var l=b.length;
		b[l]=ob[i];
	}
}
</script>
<?php
	echo $html->css('flexigrid');
	echo $html->css('start/jquery-ui-1.8.2.custom');
	
//	echo $javascript->link('jquery');
	echo $javascript->link('flexigrid/flexigrid'); 
	echo $javascript->link('namelistupload');
	echo $javascript->link('department');
	//echo $javascript->link('DatePicker/WdatePicker');
	echo $javascript->link('jquery-ui-1.8.2.custom.min');
	echo $html->css ( 'style' );
?>
<script type="text/javascript">
	$(function(){
		$(".datepickerSpan :input").datepicker({
			inline: true
		});
		 $('.datepickerSpan :input').datepicker('option', {dateFormat: "yy-mm-dd"});
		 $('.datepickerSpan :input').datepicker( "option", "closeText", 'X' );
	});
</script>
<script type="text/javascript">
$(document).ready(function(){
	$("#cancel").click(function(){
		$("#CompanymanageAddForm").reset();
		});
	$("#btnajaxAdd").click(function(){		
						$("#CompanymanageInitDetailRemarkForm").submit();
	});
	$("#bt_2").click(function(){		
		button('delete','',delurl);
	});
});
</script>
<div class="tabflex">
<table id="flex" style="display: none"></table>
</div>